package com.itheima.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component

//设置当前类为切面类
@Aspect
@Order(1)//优先级为1
public class AOPAdvice {

    //标注当前方法作为前置通知  引用切入点表达式
    @Before("AOPPointcut.pt0()")
    public void aop002log(){
        System.out.println("前置before...1");
    }




//    @Before("AOPPointcut.pt0()")
//    public void before(){
//        System.out.println("前置before...");
//    }
//
//    @After("AOPPointcut.pt0()")
//    public void after(){
//        System.out.println("后置after...");
//    }
//
//    @AfterReturning("AOPPointcut.pt0()")
//    public void afterReturing(){
//        System.out.println("返回后afterReturing...");
//    }
//
//    @AfterThrowing("AOPPointcut.pt0()")
//    public void afterThrowing(){
//        System.out.println("抛出异常后afterThrowing...");
//    }

    @Around("AOPPointcut.pt0()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前around before...");
        //接收save的返回值
        Object ret = pjp.proceed();
        System.out.println("环绕后around after..."+ret);
        return ret;
    }

//    @Before("AOPPointcut.pt0()")
//    public void aop003log(){
//        System.out.println("前置before...1");
//    }

}
